let vm = new Vue({
    el:'#main',
    data:{
        admin:{},
        roleName:{}
    },
    methods:{
        toDetail:function () {
            axios({
                url: `admin/toDetail`,
            }).then(response =>{
                this.admin = response.data.obj;
                let roles = this.admin.roles;
                let roleName = '';
                for (let i in roles) {
                    roleName += roles[i].roleName;
                    roleName += ',';
                }
                roleName = roleName.substring(0, roleName.lastIndexOf(','));
                this.roleName = roleName;
            }).catch(error=>{
                layer.msg(error.message);
            })
        },
        doUpdateDetail: function () {

            axios({
                url: "admin/doUpdateDetail",
                method: "put",
                data: this.admin
            }).then(response => {
                if(response.data.success){
                    layer.msg("更新成功");
                }else{
                    layer.msg(response.data.msg)
                }
            }).catch(error => {
                layer.msg(error);
            });
        },
    },
    created:function () {
        this.toDetail();
    }
});